News All Tests
Current file: /home/estudydev/workspace/MSP09/web/news/tests/class.newscategoryprivatemessages.inc.php
Legend: executed not executed dead code

  Coverage
  Classes Methods Lines
Total
100.00 %100.00%
100.00% 1 / 1
0.00 %0.00%
0.00% 0 / 6
3.92 %3.92%
3.92% 2 / 51
 
NewsCategoryPrivateMessages
100.00 %100.00%
100.00% 1 / 1
0.00 %0.00%
0.00% 0 / 6
2.00 %2.00%
2.00% 1 / 50
 public function __construct($catID, $courses, $userID, $categorySettings = NULL, $cacheObject = NULL)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 5
 public function isInstalled($courseID)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function canSelectPeriod()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function getNewsHeaderTitle($courseID = NULL, $type = NULL)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 8
 protected function getNewsByPeriod($courseID, $from, $to, $lastvisit, $usergroup = NULL)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 17
 protected function echoNewsEntry($entry, $courseID, $usergroup = NULL)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 17


       1                 : <?php                                                                                                                                                  
       2                 : /*--------------------------------------------------------------------------+                                                                          
       3                 : This file is part of eStudy.                                                                                                                           
       4                 : news/classes/class.NewsCategoryPrivateMessages.inc.php                                                                                                 
       5                 : - Modulgruppe:  News                                                                                                                                   
       6                 : - Beschreibung: Klasse für die News-Kategorie Private Nachrichten.                                                                                    
       7                 : - Version:      1.1.2.4, 24/01/08                                                                                                                      
       8                 : - Autor(en):    Corinna Kropf <corinna.kropf@mni.fh-giessen.de>                                                                                        
       9                 : +---------------------------------------------------------------------------+                                                                          
      10                 : This program is free software; you can redistribute it and/or                                                                                          
      11                 : modify it under the terms of the GNU General Public License                                                                                            
      12                 : as published by the Free Software Foundation; either version 2                                                                                         
      13                 : of the License, or any later version.                                                                                                                  
      14                 : +---------------------------------------------------------------------------+                                                                          
      15                 : This program is distributed in the hope that it will be useful,                                                                                        
      16                 : but WITHOUT ANY WARRANTY; without even the implied warranty of                                                                                         
      17                 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                                                                          
      18                 : GNU General Public License for more details.                                                                                                           
      19                 : You should have received a copy of the GNU General Public License                                                                                      
      20                 : along with this program; if not, write to the Free Software                                                                                            
      21                 : Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.                                                                            
      22                 : +--------------------------------------------------------------------------*/                                                                          
      23                 :                                                                                                                                                        
      24               1 : require_once ("class.newscategory.inc.php");                                                                                                           
      25                 :                                                                                                                                                        
      26                 : /**                                                                                                                                                    
      27                 :  * Klasse für die News-Kategorie Private Nachrichten.                                                                                                 
      28                 :  * @package eStudy.News                                                                                                                                
      29                 :  * @version 1.1.2.4, 24/01/08                                                                                                                          
      30                 :  * @author  Corinna Kropf <corinna.kropf@mni.fh-giessen.de>                                                                                            
      31                 :  */                                                                                                                                                    
      32               1 : class NewsCategoryPrivateMessages extends NewsCategory                                                                                                 
      33                 : {                                                                                                                                                      
      34                 :     /**                                                                                                                                                
      35                 :      * Cache Objekt zur Abfrage von Modulinstallationen (Performance Tweak)                                                                            
      36                 :      * @var array                                                                                                                                      
      37                 :      */                                                                                                                                                
      38                 :     private $installCacheObject;                                                                                                                       
      39                 :     /**                                                                                                                                                
      40                 :      * HTML-Template                                                                                                                                   
      41                 :      * @var Template                                                                                                                                   
      42                 :      */                                                                                                                                                
      43                 :     private $newsTemplate;                                                                                                                             
      44                 :        /**                                                                                                                                             
      45                 :      * @var int                                                                                                                                        
      46                 :      */                                                                                                                                                
      47                 :     private $userID;                                                                                                                                   
      48                 :     /**                                                                                                                                                
      49                 :      * Konstruktor                                                                                                                                     
      50                 :      * @param $userID int                                                                                                                              
      51                 :      */                                                                                                                                                
      52                 :     public function __construct($catID, $courses, $userID, $categorySettings = null, $cacheObject = null)                                              
      53                 :     {                                                                                                                                                  
      54               0 :         parent::__construct($catID, $courses, $categorySettings);                                                                                      
      55               0 :         $this->installCacheObject = $cacheObject;                                                                                                      
      56               0 :         $this->userID = $userID;                                                                                                                       
      57               0 :         $this->newsTemplate = new Template(PATH_TO_ROOT."news/templates/newspmentry.html");                                                            
      58               0 :     }                                                                                                                                                  
      59                 :     /**                                                                                                                                                
      60                 :      * Muss angepasst werden, falls Modulgruppen umbenannt werden!                                                                                     
      61                 :      * @see NewsCategory                                                                                                                               
      62                 :      */                                                                                                                                                
      63                 :     public function isInstalled($courseID)                                                                                                             
      64                 :     {                                                                                                                                                  
      65               0 :         return Utilities::isInstalled("messaging", $courseID, $this->installCacheObject);                                                              
      66                 :     }                                                                                                                                                  
      67                 :     /**                                                                                                                                                
      68                 :      * @see NewsCategory                                                                                                                               
      69                 :      */                                                                                                                                                
      70                 :     public function canSelectPeriod() {                                                                                                                
      71               0 :         return true;                                                                                                                                   
      72                 :     }                                                                                                                                                  
      73                 :     /**                                                                                                                                                
      74                 :      * @see NewsCategory                                                                                                                               
      75                 :      */                                                                                                                                                
      76                 :     public function getNewsHeaderTitle($courseID = null, $type = null) {                                                                               
      77               0 :         if(isset($this->news))                                                                                                                         
      78               0 :         {                                                                                                                                              
      79               0 :             $newsCount = $this->news["count"];                                                                                                         
      80               0 :             if ($newsCount > 1) $title = sprintf( $this->translate->_("%1\$s Private Nachrichten"), $newsCount);                                       
      81               0 :             elseif ($newsCount == 1) $title = $this->translate->_("1 Private Nachricht");                                                              
      82               0 :         }                                                                                                                                              
      83               0 :         else $title = $this->translate->_("Keine neuen privaten Nachrichten");                                                                         
      84                 :                                                                                                                                                        
      85               0 :         return $title;                                                                                                                                 
      86                 :     }                                                                                                                                                  
      87                 :                                                                                                                                                        
      88                 :     /**                                                                                                                                                
      89                 :      * @see NewsCategory                                                                                                                               
      90                 :      */                                                                                                                                                
      91                 :     protected function getNewsByPeriod($courseID, $from, $to, $lastvisit, $usergroup = null)  {                                                        
      92                 :         // Neue Mitteilungen                                                                                                                           
      93               0 :         if (isset($courseID) && isset($lastvisit) && isset($this->coursePreferences))                                                                  
      94               0 :         {                                                                                                                                              
      95               0 :             if(!is_numeric($courseID) || !is_numeric($lastvisit)) return null;                                                                         
      96                 :                                                                                                                                                        
      97               0 :             global $db;                                                                                                                                
      98               0 :             $this->news = array();                                                                                                                     
      99                 :                                                                                                                                                        
     100                 :             $sql =  "SELECT messaging_inbox.ID, authorID, Vorname, Nachname, gender, messaging_inbox.subject, message, date, isRead "                  
     101                 :                    ."FROM messaging_inbox LEFT OUTER JOIN user ON messaging_inbox.authorID=user.ID "                                                   
     102               0 :                    ."WHERE userID='$this->userID' "                                                                                                    
     103               0 :                    ."AND (date>=".Data::toMysql($this->getPeriod($courseID, $lastvisit)) ." "                                                          
     104               0 :                    ."OR isRead=0) "                                                                                                                    
     105               0 :                    ."ORDER BY isRead, date DESC";                                                                                                      
     106               0 :             $this->news["data"] = $db->get_results($sql);                                                                                              
     107               0 :             if ($db->num_rows == 0) $this->news = null;                                                                                                
     108                 :             else {                                                                                                                                     
     109               0 :                 foreach($this->news["data"] as $result) {                                                                                              
     110               0 :                     $this->users[$result->authorID] = $result->authorID;                                                                               
     111               0 :                 }                                                                                                                                      
     112               0 :                 $this->news["count"] = $db->num_rows;                                                                                                  
     113                 :             }                                                                                                                                          
     114               0 :         }                                                                                                                                              
     115                 :                                                                                                                                                        
     116               0 :         return $this->news;                                                                                                                            
     117                 :     }                                                                                                                                                  
     118                 :     /**                                                                                                                                                
     119                 :      * @see NewsCategory                                                                                                                               
     120                 :      */                                                                                                                                                
     121                 :     protected function echoNewsEntry($entry, $courseID, $usergroup = null)                                                                             
     122                 :     {                                                                                                                                                  
     123               0 :         if(!isset($entry) || !isset($courseID) || !isset($this->news["user"])) return;                                                                 
     124                 :                                                                                                                                                        
     125               0 :         global $db;                                                                                                                                    
     126               0 :         $userLink = $this->getProfileLink($this->news["user"], $entry->authorID, $courseID);                                                           
     127               0 :         if ($role = RoleArtefacts::getRoleForItem(PM, (int)$entry->ID)) {                                                                              
     128               0 :             $userLink.= " (".$role->getPropertiesLink($role->getName($entry->gender), $this->translate->_("Rollen-Eigenschaften anzeigen"), true) .")";
     129               0 :         }                                                                                                                                              
     130               0 :         $readMsgIcon = (!$entry->isRead) ? Output::getIcon("icon_mail", $this->translate->_("Nachricht ungelesen")) : "";                              
     131               0 :         $pmPreview = Utilities::chopText($entry->message);                                                                                             
     132               0 :         $pmDetailScript = PATH_TO_ROOT."messaging/messaging_detail.php";                                                                               
     133               0 :         $pmSubject = Utilities::chopText($entry->subject, 100);                                                                                        
     134                 :         // Date in localisierten Format                                                                                                                
     135                 :         //$pmTime = Output::echoDate("d.m.Y H:i", (int)$entry->date);                                                                                  
     136               0 :         $date = new Zend_Date((int)$entry->date, $this->locale);                                                                                       
     137               0 :         $pmTime = $date->get(Zend_Date::DATE_SHORT)                                                                                                    
     138                 :             . " "                                                                                                                                      
     139               0 :             . $date->get(Zend_Date::TIME_SHORT);                                                                                                       
     140                 :                                                                                                                                                        
     141                 :                                                                                                                                                        
     142               0 :         $g_DieseNachrichtlesen = $this->translate->_("Diese Nachricht lesen");                                                                         
     143               0 :         $g_Lesen = $this->translate->_("Lesen");                                                                                                       
     144                 :                                                                                                                                                        
     145               0 :         eval($this->newsTemplate->GetTemplate());                                                                                                      
     146               0 :     }                                                                                                                                                  
     147                 : }                                                                                                                                                      

Generated by PHPUnit 3.2.21 and Xdebug 2.0.4 at Sat Nov 7 22:04:08 CET 2009.